home
diamond Go Premium
Data Engineering Path  ·  Airflow
Apache Airflow Logo

Notification Integrations — Beyond Slack & Email

Different Failures Deserve Different Urgency

Slack and email (covered elsewhere in this course) are fine for "here's what happened." PagerDuty, Opsgenie, and Microsoft Teams exist for the narrower, more urgent question: "does a human need to wake up right now?" Using the right channel for the right severity is the actual skill here, not the API calls themselves.

A Note on This Page's Screenshots
Each of these needs a real account/API token (PagerDuty, Opsgenie, or a Teams webhook), none available in this sandbox. Code-only.

PagerDuty — Paging an On-Call Human

from airflow.providers.pagerduty.hooks.pagerduty_events import PagerdutyEventsHook

def page_oncall_on_failure(context):
    hook = PagerdutyEventsHook(pagerduty_events_conn_id="pagerduty_default")
    hook.create_event(
        summary=f"DAG {context['dag'].dag_id} failed on task {context['task_instance'].task_id}",
        severity="critical",
        source="airflow",
    )

# Wired as a callback, not a task - fires automatically on failure
@dag(
    schedule="@daily",
    start_date=...,
    on_failure_callback=page_oncall_on_failure,
)
def critical_revenue_pipeline():
    ...

Reserving PagerDuty for on_failure_callback on genuinely critical DAGs — not every DAG in a deployment — keeps it meaningful. A pager that fires for low-stakes failures trains people to ignore it.

Opsgenie

from airflow.providers.opsgenie.operators.opsgenie import OpsgenieCreateAlertOperator

create_alert = OpsgenieCreateAlertOperator(
    task_id="alert_oncall",
    opsgenie_conn_id="opsgenie_default",
    message="Sales pipeline data quality check failed",
    priority="P2",
)

Same category as PagerDuty — an incident-management platform, not a chat tool. Choice between the two is almost always "whichever one the team's on-call rotation already uses," not a technical difference in the Airflow integration itself.

Microsoft Teams

from airflow.providers.microsoft.teams.hooks.teams_webhook import TeamsWebhookHook

def notify_teams_on_failure(context):
    hook = TeamsWebhookHook(teams_webhook_conn_id="teams_default")
    hook.send(
        message=f"Pipeline {context['dag'].dag_id} failed",
        theme_color="FF0000",
    )

The Teams equivalent of the Slack integration covered elsewhere in this course — same webhook-based pattern, different destination.


Choosing By Severity, Not Habit

Situation Right channel
Routine "pipeline finished, here's a summary" Slack / Email
A failure that needs investigation this business day Slack (a dedicated alerts channel), Teams
A failure that needs someone awake at 3 AM PagerDuty / Opsgenie
Don't Page for Everything
The same discipline from the Best Practices module applies here: wiring on_failure_callback to PagerDuty on every DAG in a deployment guarantees alert fatigue within weeks. Reserve it for the small subset of DAGs where a failure is genuinely time-critical.
lock

This content is reserved for Premium Members.

Upgrade to Premium

Entity Details

Create New Item

help

Submit Technical Query

Have a question or run into an issue? Describe it below, upload an optional screenshot, and our engineering team will answer it!

image Attach image (optional)

Submit Feedback

build Free Developer Utility Free Tool
gavel

Privacy & Legal Disclaimer

1. Client-Side Browser Processing

All utility tools on DeepEngineerHub (including Image to PDF, Text Formatters, JSON Converters, and Encryptors) execute 100% locally within your client browser using WebAssembly and JavaScript. No uploaded images, text, or documents are transmitted, collected, or stored on remote servers.

2. Limitation of Liability ("As-Is" Provision)

Tools and services are provided free of charge for convenience and educational purposes "as-is" without warranties of any kind. DeepEngineerHub shall not be held liable for any data loss, formatting inconsistencies, or indirect damages resulting from tool usage.

3. Open Source & Third-Party Software

Certain utilities utilize open-source client libraries (such as jsPDF, Mermaid.js, Pyodide) licensed under MIT, Apache, or BSD open licenses. All intellectual property remains with their respective copyright holders.